/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bean.timer;

import com.bean.timer.interfaces.AbstractTimer;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics;
import java.beans.PropertyChangeSupport;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

/**
 *
 * @author Lukasz
 */
public class Timer extends AbstractTimer implements Serializable{

    private PropertyChangeSupport propertySupport;
    public Timer() {
        propertySupport = new PropertyChangeSupport(this);
        //font = new Font("DS-Digital", Font.PLAIN, this.getFontSize());
        
        InputStream inputStream = Timer.class.getResourceAsStream("/com/bean/timer/resources/Crysta.ttf");
        try{
           font = Font.createFont(Font.TRUETYPE_FONT, inputStream);
        }
        catch(FontFormatException | IOException e){
            System.out.println(e);
        }

	Font font1 = font.deriveFont (60f);
        labelTime.setFont(font1);
        labelTime.setForeground(getFontColor());
        labelTime.setText("00:00:00.0");
        
        this.add(labelTime, BorderLayout.CENTER);    
    }
    @Override
    protected void propertyChange(String property, int oldval, int newVal) {
        propertySupport.firePropertyChange(property, oldval, newVal);
    }

    @Override
    protected void propertyChange(String property, Object oldval, Object newVal) {
        propertySupport.firePropertyChange(property, oldval, newVal);
    }

    @Override
    protected void propertyChange(String property, boolean oldval, boolean newVal) {
        propertySupport.firePropertyChange(property, oldval, newVal);
    }

    @Override
    protected void propertyChange(String property, long oldval, long newval) {
        propertySupport.firePropertyChange(property, oldval, newval);
    }

    @Override
    protected void setCurrentTime(long time) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    protected void paintComponent(Graphics g) {
        g.setColor(this.getBackgroundColor());
        g.fillRect(0, 0, getSize().width, getSize().height);
        g.setColor(this.getBorderColor());
        g.drawRect(0, 0, getSize().width, getSize().height);
    }
    
    

  
    
}
